package com.example.android.ui.home;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

import com.example.android.bean.BaseModelTable;
import com.example.android.bean.CarRelease;
import com.example.android.bean.NewsBean;
import com.example.android.utils.api.CarReleaseApi;
import com.example.android.utils.api.GetRequest;
import com.example.android.utils.NetUtil;

import java.util.List;

import retrofit2.Call;

public class HomeViewModel extends ViewModel {

    private final MutableLiveData<String> mText;

    public HomeViewModel() {
        mText = new MutableLiveData<>();
        mText.setValue("This is home fragment");
    }

    public LiveData<String> getText() {
        return mText;
    }

    public LiveData<List<NewsBean>> getNewsList() {
        return NetUtil.INSTANCE.get().create(GetRequest.class).getNewsList();
    }

    public LiveData<List<NewsBean>> getAdList() {
        return NetUtil.INSTANCE.get().create(GetRequest.class).getAdList();
    }

    public LiveData<BaseModelTable<CarRelease>> getCarRelease() {
        CarRelease carRelease = new CarRelease();
        carRelease.setStatus(2);
        return NetUtil.INSTANCE.get(NetUtil.INSTANCE.getBaseUrlDev()).create(CarReleaseApi.class).getPublicRelease(carRelease);
    }

}